package sc;

import delight.nashornsandbox.*;
import java.io.File;

class ScriptContext {
   static Object eval(String cid,String jstr) {
	NashornSandbox sandbox = NashornSandboxes.create();
    sandbox.allow(Shim.class);
    //TODO get function define by cid 或者将所有chaincode揉进一个大的js中，相互调用很方便
    sandbox.eval("function pay(a,payment) { var Shim = Java.type('sc.Shim'); Shim.setState(a,payment)};");
    //val res = sandbox.eval("var x = 1 + 1; x;")
    //println(res)
    Object res = sandbox.eval(jstr);
    return res;
  }
}